﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql.Data.MySqlClient;

public partial class Default2 : System.Web.UI.Page
{
    static MySql.Data.MySqlClient.MySqlConnection connection = new MySqlConnection(GetConnectionString());

    protected void Page_Load(object sender, EventArgs e)
    {

        MySql.Data.MySqlClient.MySqlConnection mycon = new MySqlConnection(GetConnectionString());

        try
        {
            mycon.Open();

        }
        catch (MySqlException ex)
        {

            throw (ex);

        }

        
    }
    public static string GetConnectionString()
    {
        string connStr = String.Format("server={0};user id={1}; password={2};" +
          "database=cs490; pooling=false", "bai.bounceme.net",
          "root", "purdue");

        return connStr;
    }
    static public LinkedList<string[]> getDestionations(string country)
    {
        MySqlCommand command = connection.CreateCommand();
        MySqlDataReader reader = null;
        LinkedList<String[]> returnlist = new LinkedList<String[]>();

        command.CommandText = "select * from destination where country=\"" + country + "\"";
        connection.Open();
        reader = command.ExecuteReader();
        while (reader.Read())
        {
            string[] addarr = new string[4];
            addarr[0] = reader.GetString(0);
            addarr[1] = reader.GetString(1);
            addarr[2] = reader.GetString(3);
            addarr[3] = reader.GetString(4);
            returnlist.AddFirst(addarr);
        }
        connection.Close();

        return returnlist;
    }
}